#pragma once

#include "Container.h"
#include "Config.h"

namespace db
{

template <class T, ERecordType ID>
class SimpleContainer : public Container
{
private:
    T               m_data;
public:

    void Load(ReadStream& file)
    {
        file.read(&m_data, sizeof(m_data));
    }

    void Save(WriteStream& file) const
    {
        file.write(&m_data, sizeof(m_data));
    }
public:
    SimpleContainer() :
        m_data((T)0)
    {

    }
    SimpleContainer(const T data) :
        m_data(data)
    {

    }
public:
    ERecordType GetType() const { return ID; }

    std::wstring GetAsString() const
    {
		std::wstringstream str;
		str << m_data;
		return str.str();
    }

    bool GetAsBool() const
    {
        return m_data ? true : false;
    }

    u32 GetAsInt() const
    {
        return static_cast<u32>(m_data);
    }

    f32 GetAsFloat() const
    {
        return static_cast<f32>(m_data);
    }

    f64 GetAsDouble() const
    {
        return static_cast<f64>(m_data);
    }
	
	u32 GetDataSize() const
	{
		return sizeof(m_data);
	}

	const void* GetAsData() const
	{
		return &m_data;
	}

    T Get() { return m_data; }
    void Set(const T data) { m_data = data; }
};

};